package com.example.userblog.controller;

import cn.hutool.core.date.DateUtil;
import com.example.userblog.common.Result;
import com.example.userblog.entity.Article;
import com.example.userblog.entity.Product;
import com.example.userblog.service.ArticleService;
import com.example.userblog.service.ProductService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("product")
public class ProductController {
    @Resource
    ProductService productService;
    @PostMapping("list")
    public Result getData(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "5") Integer size){

        return Result.success(productService.getAll(page,size));
    }
    @PostMapping("add")
    public Result addProduct(@RequestBody Product product){
        product.setCreateTime(DateUtil.now());
        return Result.success(productService.add(product));

    }
}
